<?php
include dirname(dirname(__FILE__)).'/admin-verify.php';
include dirname(__FILE__)."/functions.php";
if(isset($_POST['submited'])&&$_POST['submited']==1) {
	$val=addslashes($_POST["data"]);
	$arr=explode(",", $val);
	$ret=applyList($arr[0], $arr[1]);
}
?>
<html>
	<head>
		<title>申请列表</title>
			<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php'; ?>

		<script type="text/javascript">
		$(document).ready(function() {
			$(".pass").click(function(){
				var val=$.trim($(this).next().val());
				$.post("ajax/apply-pass.php",{val:val},function(result){
					
					location.href="../place-apply-manage/index.php";
					
				  });
				
				});
			$(".show").click(function(){
			var val=$.trim($(this).next().val());
				$.post("ajax/show-s_user.php",{val:val},function(result){
					//json=JSON.parse();
					var obj = eval('(' + result + ')');  //string 转化 json
					$("#username").html(obj.username);
					$("#student_id").html(obj.student_id);
					$("#department").html(obj.department);
					$("#grade").html(obj.grade);
					$("#user_real_name").html(obj.user_real_name);
					$("#sex").html(obj.sex);
					$("#phone").html(obj.phone);
					
					
					
					
				  });
				});
		});
		</script>
	</head>
	<body>	
	
	
<div class="modal fade" id="myModal-show" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
 
<h4 class="modal-title" id="myModalLabel">用户信息</h4>
</div>
<div class="modal-body">
	        <form class="form-horizontal col-md-offset-3">
			  <div class="form-group">
			    <label for="username" class="col-sm-2 control-label">用户名</label>
			    <div class="col-sm-10">
			      <h4 style="width:60%"   id="username" name="username" ></h4>
			    </div>
			  </div>		
			    <div class="form-group">
				    <label for="student_id" class="col-sm-2 control-label">学号</label>
				    <div class="col-sm-10">
				      <h4 style="width:60%" name="student_id"  id="student_id" ></h4>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="department" class="col-sm-2 control-label">学院</label>
				    <div class="col-sm-10">
				      <h4 style="width:60%"  name="department"  id="department" ></h4>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="grade" class="col-sm-2 control-label">年级</label>
				    <div class="col-sm-10">
				      <h4 style="width:60%"  name="grade" id="grade" ></h4>
				    </div>
				  </div>
				  <div class="form-group">
				    <label  for="user_real_name" class="col-sm-2 control-label">姓名</label>
				    <div class="col-sm-10">
				      <h4  style="width:60%"  name="user_real_name" id="user_real_name"></h4>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="sex" class="col-sm-2 control-label">性别</label>
				    <div class="col-sm-10">
				       <h4 style="width:60%" name="sex" id="sex" ></h4>
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="phone" class="col-sm-2 control-label">联系方式</label>
				    <div class="col-sm-10">
				      <h4 style="width:60%"  name="phone"  id="phone" ></h4>
				    </div>
				  </div>
			</form>
	      </div>
	    </div>
	  </div>
	</div>
	
			<div class="container">
 						<table class="table table-striped table-bordered table-hover table-condensed default-table">
			  <tr>
			  	<th>用户</th>
			  	<th>场地时间</th>
			  	<th>时间 段</th>
			  	<th>申请时间</th>
			  <!-- <th>材料</th>-->
			  	<th>状态</th>
			  	<th>操作</th>
			  </tr>
			  <?php
			  		if ($ret) {
						$i=1;
						
						
							while ($row=mysql_fetch_array($ret)){
								$start=8+$row["period"]*2;
								$end=10+$row["period"]*2;
								echo "<tr>";
								echo "<th>".'<button class="btn btn-primary show" data-toggle="modal" 
										data-target="#myModal-show">'.$row["username"].'</button>'
								.'<input type="hidden" value="'.base64_encode($row['id']).'"/>'."</th>";
								echo "<th>".$row['date']."</th>";
								echo "<th>".$start."~".$end."点"."</th>";
								echo "<th>".$row['create_time']."</th>";
								if($row['status']==0){
									
									echo "<th>"."审核中"."</th>";
									echo "<th>".'<a href="javascript:void(0);"
							class="btn btn-primary pass" role="button" >通过审核</a><input type="hidden" value="'.$row["id"].",".$row["pat_id"].",".$row["pa_id"].",".$row["period"].'" />'."</th>";
									
								}
								if($row['status']==1){
										
									echo "<th>"."通过申请"."</th>";
									echo "<th>".'<a href="javascript:void(0);"
								class="btn btn-primary disabled" role="button" >操作完成</a>'."</th>";
										
								}
								if($row['status']==2){
								
									echo "<th>"."申请失败"."</th>";
									echo "<th>".'<a href="javascript:void(0);"
								class="btn btn-primary disabled" role="button" >操作完成</a>'."</th>";
								
								}
								
								echo "</tr>";
								$i++;
							}
			  		} 
			  ?>
			  
			</table>
 				</div>
	
	
	
	
	
	
	</body>
</html>